package guoanmaker.operator.business.controller;

import java.util.Date;
import java.util.List;



import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import guoanmaker.operator.business.model.BackgroundPicture;
import guoanmaker.operator.business.model.InRoundPhone;

import guoanmaker.operator.business.service.OperatorBackgroundPictureServiceInterface;
import guoanmaker.operator.helper.common.AjaxJson;
import guoanmaker.operator.helper.common.abstractobj.ApiController;
import io.swagger.annotations.ApiOperation;
/**
 * 运营端登录背景图配置
* @ClassName: OperatorBackgroundPictureController
* @Description:TODO (这里用一句话描述这个类的作用) 
* @author lihongyu
* @date 2017年9月4日 下午8:21:43 
*  
 */
@RestController
@RequestMapping(ApiController.OPERATOR_BACKGROUND_PICTURE)
public class OperatorBackgroundPictureController {
	@Autowired
	private OperatorBackgroundPictureServiceInterface operatorBackgroundPictureServiceInterface;
	  @ApiOperation(value = "保存登录页面背景图", notes = "保存登录页面背景图包括新增与修改 ")
	    @PostMapping(value = "saveBackgroundPicture")
	    public AjaxJson saveBackgroundPicture(@RequestBody InRoundPhone inRoundPhone) {
		  AjaxJson ajaxJson=new AjaxJson();
	    	try{
	    		BackgroundPicture ow=inRoundPhone.getBackgroundPicture();
	    		ow.setCreatDate(new Date());
	    		BackgroundPicture    backgroundPicture = operatorBackgroundPictureServiceInterface.saveBackgroundPicture(ow);
	        ajaxJson.setSuccess(true).setStatus(200).setData(backgroundPicture);
	    	}catch(Exception e){
	    		e.printStackTrace();
	    		 ajaxJson.setSuccess(true).setStatus(250).setData(null);
	    	}
	        return ajaxJson;
	    }
	  
	  @ApiOperation(value = "查询所有欢迎语", notes = "查询所有欢迎语")
	    @PostMapping(value = "getAllBackgroundPicture")
	  public AjaxJson getAllBackgroundPicture() {
		  AjaxJson ajaxJson=new AjaxJson();
	    	try{
	    	List<BackgroundPicture> ops=operatorBackgroundPictureServiceInterface.getAllBackgroundPicture();
	        ajaxJson.setSuccess(true).setStatus(200).setData(ops.get(0));
	        
	    	}catch(Exception e){
	    		e.printStackTrace();
	    		 ajaxJson.setSuccess(false).setStatus(250).setData(null);
	    	}
	    	return ajaxJson;
	    }
	  
}
